<?php
/**
 * Created by PhpStorm.
 * User: 12133
 * Date: 2022/12/9
 * Time: 19:15
 */

namespace app\controller;


use app\model\app\AppKefuClick;
use app\model\app\AppPayOrder;
use app\model\app\AppUserBasic;
use app\model\tb\TbUser;

class Count
{
    public function today(){
        $register_count = $new_login_count = TbUser::where('create_time','>',date('Y-m-d'))->count();
        $old_login_count = TbUser::where('update_time','>',date('Y-m-d'))->where('create_time','<',date('Y-m-d'))->count();
        $finish_order = AppPayOrder::where('status',1)->count();
        $finish_amount = AppPayOrder::where('status',1)->sum('pay_amount');
        $kefu_click_count = AppKefuClick::where('create_time',date('Y-m-d'))->sum('click');
        $pay_click_count = AppKefuClick::where('create_time',date('Y-m-d'))->sum('pay_click');
        $basic_finish_count = AppUserBasic::where('update_time','>',date('Y-m-d'))
            ->where('birthday','NOT NULL')
            ->where('gender','NOT NULL')
            ->where('married','NOT NULL')
            ->where('fullname','NOT NULL')
            ->where('email','NOT NULL')
            ->where('employment_type','NOT NULL')
            ->where('uncome_monthly','NOT NULL')
            ->where('working_since','NOT NULL')
            ->where('ifsc_code','NOT NULL')
            ->where('branch_name','NOT NULL')
            ->where('bank_account_no','NOT NULL')
            ->where('adahaar_number','NOT NULL')
            ->where('adahaar_front','NOT NULL')
            ->where('adahaar_back','NOT NULL')
            ->where('score','NOT NULL')
            ->count();
        return json(['code' => 200,'msg' => '','data' => [
            'register_count' => $register_count,
            'new_login_count' => $new_login_count,
            'old_login_count' => $old_login_count,
            'finish_order' => $finish_order,
            'finish_amount' => $finish_amount,
            'basic_finish_count' => $basic_finish_count,
            'kefu_click_count' => $kefu_click_count,
            'pay_click_count' => $pay_click_count
        ]]);
    }
    public function total(){
        $finish_order = AppPayOrder::sum('pay_amount');
        $finish_amount = AppPayOrder::where('status',1)->sum('pay_amount');
        return json(['code' => 200,'msg' => '','data' => [
            'finish_order' => $finish_order,
            'finish_amount' => $finish_amount
        ]]);
    }
}